import { defineBoot } from "#q-app/wrappers";

const roleBtns: string[] = [];

export default defineBoot(({ app }) => {
  app.directive("require", {
    mounted(el, binding) {
      const { value } = binding;
      const content = value && value.content ? value.content : "*";
      const color = value && value.color ? value.color : "#e04407";
      const r = document.createElement("div");
      r.innerHTML = content;
      r.style.position = "relative";
      r.style.width = "0px";
      r.style.height = "0px";
      r.style.left = "-10px";
      r.style.color = color;
      el.insertBefore(r, el.childNodes[0]);
    }
  });
  app.directive("access", {
    mounted(el, binding) {
      const { value } = binding;
      // 非管理员用户
      if (value && value !== "") {
        if (!roleBtns.includes(value)) {
          el.parentNode.removeChild(el);
        }
      }
    }
  });

  console.log(app);

  app.directive("title", {
    // mounted(el, binding) {
    //   const setting = binding.value;
    //   const color = setting && setting.color ? setting.color : "#1972D6";
    //   const r = document.createElement("div");
    //   r.style.content = "";
    //   r.style.position = "absolute";
    //   r.style.width = "0.25rem";
    //   r.style.height = "1.5rem";
    //   r.style.left = "0";
    //   r.style.top = "1.2rem";
    //   r.style.backgroundColor = color;
    //   el.insertBefore(r, el.childNodes[0]);
    // }
  });
  // app.directive("title", {});
});
